var http = require("http");

var config = require("./config").config;

// var persons = require("./responseData").persons;
var slidepages = require("./responseData").slidepages;

var server = http.createServer(function(request,response){
    // console.log("request success");
    // response.header("Access-Control-Allow-Origin", "*");
    response.setHeader("Access-Control-Allow-Origin","*");
    // response.header("Access-Control-Allow-Headers", "X-Requested-With");
    // response.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
    // response.header("X-Powered-By",' 3.2.1');
    response.setHeader("Content-Type", "application/json;charset=utf-8"); // 加上 charset=utf-8 是为了防止数据传输中出现乱码
    response.statusCode = 200;
    // response.writeHead(200,{ "Cpntent-Type":"application/json" });
    // response.write(JSON.stringify(persons));
    response.end(JSON.stringify(slidepages));
});

server.listen(config.port,config.hostname,function(){
    console.log(`server running at http://${config.hostname}:${config.port}`);
});

// 使用 JSON.parse() 可以解析 json

